<template>
  <t-card class="dashboard-detail-card" :style="{ height: '464px' }">
    <div class="heard-box hw-flex-style-b-c">
      <span class="heard-title">成员</span>
      <div class="action-box hw-click-cursor">
        <div class="action-item" v-if="props.role == 1">
          <i class="doorIcon action-item-r-icon" @click="visible1 = true">&#xe650;</i>
          <!-- <img src="https://static-1316349889.cos.ap-shanghai.myqcloud.com/assets/img/ic_user-add.svg" alt="" @click="visible1 = true" /> -->
        </div>
        <div class="action-item action-item-r" @click="lookWhole">
          <i class="doorIcon action-item-r-icon">&#xe651;</i>
          <!-- <img src="https://static-1316349889.cos.ap-shanghai.myqcloud.com/assets/img/ic_setting.svg" alt="" /> -->
        </div>
      </div>
    </div>
    <t-table
      maxHeight="360px"
      row-key="index"
      :data="props.info.members"
      :columns="columns"
      :table-content-width="tableLayout === 'fixed' ? undefined : '100%'"
      :resizable="false"
    >
      <template #name="{ row }">
        <div class="hw-box-style-flex hw-box-style-flex-r-center">
          <t-avatar size="30px" v-if="row.coverUrl" :image="urls + row.coverUrl + webUrls"></t-avatar>
          <t-avatar
            size="30px"
            v-else
            image="https://static-1316349889.cos.ap-shanghai.myqcloud.com/assets/img/userImg.png"
          ></t-avatar>
          <span class="user-name">{{ row.name }}</span>
          <span class="isOneself hw-flex-style-c-c" v-if="row.isOneself">我</span>
        </div>
      </template>

      <template #role="{ row }">
        <div
          class="row-role"
          :class="{ 'row-role-1': row.role == 1, 'row-role-2': row.role == 2, 'row-role-3': row.role == 3 }"
        >
          {{ row.role == 1 ? '创建者' : row.role == 2 ? '参与人' : '参与人' }}
        </div>
      </template>
    </t-table>
    <invite
      v-if="visible1"
      @closes="closes"
      :inviteId="Number(route.query.projectId)"
      :visible="visible1"
      :refType="3"
      :authenticationId="Number(route.query.projectId)"
    ></invite>
  </t-card>
</template>

<script setup lang="ts">
// @ts-nocheck
import { useRoute } from 'vue-router';
import { urls } from '@/utils/request/upload';
import invite from '@/components/invite/invite.vue';
import { ref } from 'vue';
import { BUY_COLUMNS } from '../data';
import { useRouter } from 'vue-router';

const webUrls: string = '?imageView2/2/w/30/h/30/format/webp';
const route = useRoute();
const router = useRouter();
const props = defineProps({
  info: {
    type: Object,
  },
  role: {
    type: Number,
  },
});
const visible1 = ref(false);
const tableLayout = ref('fixed');
const columns = BUY_COLUMNS;
const lookWhole = () => {
  // router.push('/prijectMenu/member');
  router.push({ path: '/prijectMenu/member', query: { projectId: localStorage.getItem('projectId') } });
};
const closes = () => {
  visible1.value = false;
};
</script>

<style lang="less" scoped>
.t-avatar {
  flex-shrink: 0;
}

.card-content {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  width: 100%;
  min-height: 257px;
  overflow-y: auto;
}
.item-box {
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.item-img {
  width: 48px;
  height: 48px;
  background: #d8d8d8;
}
.item-text {
  font-size: 16px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #666666;
  line-height: 17px;
  margin-top: 8px;
}
.row-role-1 {
  background: @color-text-color;
  color: #fff;

  border: 3px;
}
.row-role-2 {
  background: #f1eceb;
  color: rgba(0, 0, 0, 0.38);

  border: 3px;
}
.row-role-3 {
  background: #f1eceb;
  color: rgba(0, 0, 0, 0.38);

  border: 3px;
}
.row-role {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 64px;
  height: 24px;
  border-radius: @radius-hw-box1;
  font-size: 14px;
  margin: 0 auto;
}
.action-box {
  display: flex;
}
.action-item {
  // border: 1px solid #999;
  margin-left: 24px;
  .doorIcon {
    font-size: 24px;
    color: RGBA(158, 158, 158, 1);
  }
}
.action-item-r {
  border-left: none;
}
.action-item-r-icon:hover {
  color: #f2573f;
}
.heard-box {
  height: 60px;
}
.heard-title {
  font-size: 18px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.8);
  line-height: 28px;
}
:deep(.t-card__body) {
  padding-top: 0 !important;
}
.user-name {
  max-width: 68px;
  font-size: 16px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.9);
  line-height: 20px;
  margin-left: 8px;
  white-space: nowrap; /* 不换行 */
  overflow: hidden; /* 溢出隐藏 */
  text-overflow: ellipsis; /* 显示省略号 */
}
.isOneself {
  width: 30px;
  height: 20px;
  border-radius: 10px;

  background: #e62b17;
  color: #fff;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #ffffff;
  line-height: 20px;
  margin-left: 8px;
}
:deep(.t-table__header--fixed:not(.t-table__header--multiple) > tr > th) {
  background: #f5f5f5;
}
:deep(.t-table th, .t-table td) {
  border-color: #fff;
}
:deep(.t-table__th-cell-inner) {
  font-size: 14px;
}
:deep(.t-table__header) {
  height: 48px;
}
:deep(.t-table__body tr) {
  height: 60px;
}
:deep(.t-table__body tr td) {
  border-bottom: none !important;
}
:deep(.t-table__header.t-table__header--fixed) {
  z-index: 9 !important;
}
.hw-box-style-flex {
  min-width: 120px;
}
:deep(.t-table__header) {
  background: #f5f5f5;
  height: 30px;
}
</style>
